function walidujPesel(p) {
//TODO nie działa poprawnie 90050212098
	if (p.length == 11) {

		p += '';
		var arr = p.split("");

		var ratio = 0;

		ratio += parseInt(arr[0]) * 1;
		ratio += parseInt(arr[1]) * 3;
		ratio += parseInt(arr[2]) * 7;
		ratio += parseInt(arr[3]) * 9;
		ratio += parseInt(arr[4]) * 1;
		ratio += parseInt(arr[5]) * 3;
		ratio += parseInt(arr[6]) * 7;
		ratio += parseInt(arr[7]) * 9;
		ratio += parseInt(arr[8]) * 1;
		ratio += parseInt(arr[9]) * 3;

		var controlInt = ratio % 10;

		var controlSum = parseInt(p.substr(10, 1));

		if (controlInt != controlSum) {
			document.getElementById('pesel').setAttribute('style', 'border: 2px solid red');
			document.getElementById('pesel').value += ' BŁĄD';
		} else {
			document.getElementById('pesel').setAttribute('style', 'border: 1px solid #AAAAAA');
		}

	} else {
		document.getElementById('pesel').setAttribute('style', 'border: 2px solid red');
	}

}

function walidujNip(nip) {
	
	nip+='';
	
	nip=nip.replace(/[^0-9]+/g,'');
	
	if(nip.length == 10) {
		
	var controlSum=0;
	
	controlSum+=parseInt(nip.charAt(0))*6;
	controlSum+=parseInt(nip.charAt(1))*5;
	controlSum+=parseInt(nip.charAt(2))*7;
	controlSum+=parseInt(nip.charAt(3))*2;
	controlSum+=parseInt(nip.charAt(4))*3;
	controlSum+=parseInt(nip.charAt(5))*4;
	controlSum+=parseInt(nip.charAt(6))*5;
	controlSum+=parseInt(nip.charAt(7))*6;
	controlSum+=parseInt(nip.charAt(8))*7;
	
	if((controlSum%11)==parseInt(nip.charAt(9))) { 
		document.getElementById('nip').setAttribute('style', 'border: 1px solid #AAAAAA');
	} else { 
		document.getElementById('nip').setAttribute('style', 'border: 2px solid red');
		document.getElementById('nip').value += ' BŁĄD';
	}
	
	} else {
		document.getElementById('nip').setAttribute('style', 'border: 2px solid red');
	}
}